package source;

import util.BigPrime;
import eduni.simjava.*;
import eduni.simjava.distributions.Sim_negexp_obj;
import eduni.simjava.distributions.Sim_poisson_obj;

public class ClientManager extends Sim_entity{
    private Sim_port outT, outC;
    private Sim_poisson_obj delay;
    private double lastTime;
    private int arrivedClients;
    
    public ClientManager(String name, double lambda, int arrivedClients) {
        super(name);
        this.arrivedClients = arrivedClients;
        outT = new Sim_port("outT");
        //outC = new Sim_port("outC");        
        add_port(outT);
        //add_port(outC);        

        delay = new Sim_poisson_obj("Poisson", lambda, BigPrime.getSeed());
        add_generator(delay);
    }

    @Override
    public void body() {
   
        for (int i = 0; i < this.arrivedClients; i++) {
        	
        	double wait = delay.sample();
            //sim_process(wait);
            sim_schedule(outT, 0.0, 1, new Client());
        }


    }
    

	public int getArrivedClients() {
		return arrivedClients;
	}

	public void setArrivedClients(int arrivedClients) {
		this.arrivedClients = arrivedClients;
	}
}